package gold.digger;

import gold.utils.InputUtil;
import jdk.internal.util.xml.impl.Input;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.List;
import java.util.TreeMap;

/**
 * Created by fanzhenyu02 on 2020/6/27.
 * common problem solver template.
 */
public class LC506 {
    public long startExecuteTime = System.currentTimeMillis();


    class Solution {
        public String[] findRelativeRanks(int[] score) {
            TreeMap<Integer, Integer> cnt = new TreeMap<>(Comparator.reverseOrder());
            for (int i = 0; i < score.length; i++) {
                cnt.put(score[i], i);
            }

            String[] res = new String[score.length];
            int order = 0;
            for (Integer sc : cnt.keySet()) {
                if (order == 0) res[cnt.get(sc)] = "Gold Medal";
                else if (order == 1) res[cnt.get(sc)] = "Silver Medal";
                else if (order == 2) res[cnt.get(sc)] = "Bronze Medal";
                else res[cnt.get(sc)] = String.valueOf(order + 1);
                ++order;
            }

            return res;
        }
    }

    public void run() {
        Solution solution = new Solution();
        System.out.println(Arrays.toString(solution.findRelativeRanks(InputUtil.toIntegerArray("[5,4,3,2,1]"))));
    }

    public static void main(String[] args) throws Exception {
        LC506 an = new LC506();
        an.run();

        System.out.println("\ncurrent solution total execute time: " + (System.currentTimeMillis() - an.startExecuteTime) + " ms.");
    }
}
